upgrader: Add ostree_sysroot_upgrader_dup_origin()
authorMatthew Barnes <mbarnes@redhat.com>
Tue, 6 Oct 2015 15:24:23 +0000 (11:24 -0400)
committerMatthew Barnes <mbarnes@redhat.com>
Tue, 13 Oct 2015 16:34:56 +0000 (12:34 -0400)
Convenience function returns a copy of the origin file, useful when
modifying it.

doc/ostree-sections.txt
src/libostree/ostree-sysroot-upgrader.c
src/libostree/ostree-sysroot-upgrader.h

index 84ba417e23cb0801b5816af77ecb55a8fb2b1fae..ff512e470441f16b697f5923cb267070708aaf64 100644 (file)
@@ -410,6 +410,7 @@ ostree_sysroot_upgrader_new_for_os
 OstreeSysrootUpgraderFlags
 ostree_sysroot_upgrader_new_for_os_with_flags
 ostree_sysroot_upgrader_get_origin
+ostree_sysroot_upgrader_dup_origin
 ostree_sysroot_upgrader_set_origin
 ostree_sysroot_upgrader_get_origin_description
 ostree_sysroot_upgrader_check_timestamps
index 3012d31e034dca06f13e815d4404d486beb47e3a..7ee19f631dc2b2ecdb700b99bcc2bbcda6e66abb 100644 (file)
@@ -341,6 +341,33 @@ ostree_sysroot_upgrader_get_origin (OstreeSysrootUpgrader *self)
   return self->origin;
 }
 
+/**
+ * ostree_sysroot_upgrader_dup_origin:
+ * @self: Sysroot
+ *
+ * Returns: (transfer full): A copy of the origin file, or %NULL if unknown
+ */
+GKeyFile *
+ostree_sysroot_upgrader_dup_origin (OstreeSysrootUpgrader *self)
+{
+  GKeyFile *copy = NULL;
+
+  g_return_val_if_fail (OSTREE_IS_SYSROOT_UPGRADER (self), NULL);
+
+  if (self->origin != NULL)
+    {
+      g_autofree char *data = NULL;
+      gsize length = 0;
+
+      copy = g_key_file_new ();
+      data = g_key_file_to_data (self->origin, &length, NULL);
+      g_key_file_load_from_data (copy, data, length,
+                                 G_KEY_FILE_KEEP_COMMENTS, NULL);
+    }
+
+  return copy;
+}
+
 /**
  * ostree_sysroot_upgrader_set_origin:
  * @self: Sysroot
index edac5a3d60ce678c5a6071cbe5d135be1279f57c..394e31a3297a19db9006179aaf4547074bd08bdd 100644 (file)
@@ -62,6 +62,7 @@ OstreeSysrootUpgrader *ostree_sysroot_upgrader_new_for_os_with_flags (OstreeSysr
                                                                       GError                    **error);
 
 GKeyFile *ostree_sysroot_upgrader_get_origin (OstreeSysrootUpgrader *self);
+GKeyFile *ostree_sysroot_upgrader_dup_origin (OstreeSysrootUpgrader *self);
 gboolean ostree_sysroot_upgrader_set_origin (OstreeSysrootUpgrader *self, GKeyFile *origin,
                                              GCancellable *cancellable, GError **error);